<template>
  <div>
   <!-- <div style="height: 40px;margin-right: 150px; margin-bottom: 10px">

      <div style="float: right; ">
        <el-button type="primary" size="mini" @click="showAdd">预定</el-button>
      </div>
    </div>-->
    <div style="margin-top: 10px">
      <div v-for="(item, index) in companyList" style="margin-left: 150px; ">
        <div style="width: 20%; height: 230px; float: left; margin-bottom: 24px;
        margin-right: 14px; border-radius: 10px; border: 1px dashed #778899;
        padding: 20px; text-align: center">
          <img :src="baseApi + '/recruit/' + item.img" style="width: 100px; height: 70px; border-radius: 10px">
          <div style="margin-top: 10px">{{item.name}}</div>
          <div style="">{{item.foreignName}}</div>
          <div style="margin-top: 10px">{{item.mission}}</div>
            <!--
          <div style="font-weight: bold;margin-left: 170px; margin-top: 8px; color: red">
            ￥{{item.tickets}}
          </div>-->
        </div>

      </div>
    </div>

    <el-dialog
      append-to-body
      :close-on-click-modal="false"
      :before-close="cancelCU"
      :visible="visible"
      title="购买门票"
      width="500px"
    >
      <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">

        <el-form-item label="会员手机" prop="phoneNum">
          <el-input
            v-model="form.phoneNum"
            style="width: 370px;"
          />
        </el-form-item>

        <el-form-item label="名称" prop="name">
          <el-input
            v-model="form.name"
            style="width: 370px;"
          />
        </el-form-item>

        <el-form-item label="价格" prop="price">
          <el-input
            v-model="form.price"
            style="width: 370px;"
          />
        </el-form-item>

        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form.remark"
            style="width: 370px;"
          />
        </el-form-item>

      </el-form>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button type="text" @click="cancelCU">取消</el-button>
        <el-button type="primary" @click="submitCU">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { getCompanyList } from '../../../api/ceamCompany'
  import { add } from '@/api/ceamStar'
  import { mapGetters } from 'vuex'

  export default {
    name: 'LandSpace',
    data() {
      return {
        companyList: [],
        visible: false,
        form: {}
      }
    },
    computed: {
      ...mapGetters([
        'baseApi'
      ])
    },
    created() {
      this.getLandSpaceList();
    },

    methods: {
      getLandSpaceList() {
        console.log('获取数据')
        const params = {
          page: 0,
          size: 100,
          status: 2
        }
        getCompanyList(params).then(res => {
          this.companyList = res.records;
        })
      },
      showAdd() {
        this.visible = true;
      },
      cancelCU() {
        this.visible = false;
      },
      submitCU() {
        add(this.form).then(res => {
          this.visible = false;
          this.$message({
            message: '添加成功',
            type: 'success'
          })
        }).catch(error => {
          this.$message({
            message: '添加失败',
            type: 'waring'
          })
        })
      }
    }
  }
</script>

<style scoped>

</style>
